package com.feign.wugongbang.controller;

import com.feign.wugongbang.entity.WgbErrorCollection;
import com.feign.wugongbang.service.ErrorCollctionService;
import com.feign.wugongbang.utils.BeanAndMapTranslate;
import com.feign.wugongbang.utils.Constants;
import com.feign.wugongbang.utils.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by Administrator on 2017/5/24.
 */
@RefreshScope
@RestController
@RequestMapping(value = Constants.CODE_VERSION +"/errorCollction")
public class ErrorCollctionController {

    @Autowired
    private ErrorCollctionService errorCollctionService;

    @Value("${encode.word:test}")
    private String value;

    @RequestMapping(value = "/value",method = RequestMethod.GET)
    public Object value() throws Exception{
        return value;
    }

    @RequestMapping(value = "/insert",method = RequestMethod.POST)
    public Object insert(WgbErrorCollection errorCollection) throws Exception{
        return errorCollctionService.insert(BeanAndMapTranslate.objectToMap(errorCollection));
    }

    @RequestMapping(value = "/selectByPrimaryKey",method = RequestMethod.GET)
    public Object selectByPrimaryKey(String id){
        return errorCollctionService.selectByPrimaryKey(id);
    }

    @RequestMapping(value = "/updateByPrimaryKey",method = RequestMethod.POST)
    public Object updateByPrimaryKey(WgbErrorCollection errorCollection) throws Exception {
        return errorCollctionService.updateByPrimaryKey(BeanAndMapTranslate.objectToMap(errorCollection));
    }

    @RequestMapping(value = "/selectAll",method = RequestMethod.POST)
    public Object selectAll(@RequestBody PageInfo pageInfo){
        return errorCollctionService.selectAll(pageInfo);
    }

    @RequestMapping(value = "/deleteByPrimaryKey",method = RequestMethod.GET)
    public Object deleteByPrimaryKey(String id){
        return errorCollctionService.deleteByPrimaryKey(id);
    }
}
